home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-08-10 | 54.7 KB | 2,090 lines |
- #!/bin/sh
- # to extract, remove the header and type "sh filename"
- if `test ! -d ./src`
- then
- mkdir ./src
- echo "mkdir ./src"
- fi
- if `test ! -s ./src/makefile`
- then
- echo "writing ./src/makefile"
- cat > ./src/makefile << 'E_O_F'
- # Makefile for TeXtyl
- # Tue May 26 1987 John S. Renner
- # be sure to edit texpaths.h to reflect local directory conventions
- # before compiling
- textyl: textyl.pas tylext.o tylext.h
- /lib/cpp -P textyl.pas textyl.p
- pc -w -c textyl.p
- rm -f textyl.p
- pc -o textyl textyl.o tylext.o
-
- SRCS = textyl.pas.aa textyl.pas.ab textyl.pas.ac \
- textyl.pas.ad textyl.pas.ae textyl.pas.af \
- textyl.pas.ag textyl.pas.ah
-
- textyl.pas: $(SRCS)
- cat $(SRCS) > textyl.pas
-
- tylext.o: tylext.c texpaths.h h00vars.h
- cc -c tylext.c
-
- clean:
- /bin/rm -f *.o textyl.p
-
- E_O_F
- else
- echo "will not over write ./src/makefile"
- fi
- chmod 644 ./src/makefile
- if [ `wc -c ./src/makefile | awk '{printf $1}'` -ne 557 ]
- then
- echo `wc -c ./src/makefile | awk '{print "Got " $1 ", Expected " 557}'`
- fi
- if `test ! -s ./src/tylext.h`
- then
- echo "writing ./src/tylext.h"
- cat > ./src/tylext.h << 'E_O_F'
- procedure setpaths;
- external;
-
- function testaccess(accessmode:integer; filepath:integer): boolean;
- external;
- E_O_F
- else
- echo "will not over write ./src/tylext.h"
- fi
- chmod 644 ./src/tylext.h
- if [ `wc -c ./src/tylext.h | awk '{printf $1}'` -ne 117 ]
- then
- echo `wc -c ./src/tylext.h | awk '{print "Got " $1 ", Expected " 117}'`
- fi
- if `test ! -s ./src/textyl.pas.ag`
- then
- echo "writing ./src/textyl.pas.ag"
- cat > ./src/textyl.pas.ag << 'E_O_F'
- procedure tylBrokenLine (x0, y0, x1, y1, fontindex : integer;
- line_type: LineStyle);
- label 10;
- var useXaxis: boolean;
- a0, b0, a1, b1: integer;
- a2, a3, b2, b3, K, gap, dot, dash: integer;
- s, z, fit: real;
- J, frame, T: integer;
- Dotgap, Dotdot: integer;
- Dashgap, Dashdash: integer;
- DDotgap, DDotdot, DDotdash: integer;
- a1ma0 : integer;
-
- {.........................................................}
- procedure spread (lt : LineStyle; extra, T : integer);
- label 20;
- begin
- if (T = 0) then
- begin { only partial frame fits }
- if (useXaxis) then
- diagonal (a0, b0, a1, b1, fontindex)
- else
- diagonal (b0, a0, b1, a1, fontindex);
- goto 20; { exit }
- end;
- J := 0;
- s := float (b1 - b0)/float(a1 - a0);
- z := float (extra)/float(T);
- case lt of
- dotted : repeat a2 := a0 + J*frame;
- if (extra > 0) then a2 := a2 + round(J*z);
- a3 := a2 + dot;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- end;
- J := J + 1;
- until (a3 >= a1);
- dashed : repeat a2 := a0 + J*frame;
- if (extra > 0) then a2 := a2 + round(J*z);
- a3 := a2 + dash;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- end;
- J := J + 1;
- until (a3 >= a1);
- dotdash : repeat a2 := a0 + J*frame;
- if (extra > 0) then a2 := a2 + round(J*z);
- a3 := a2 + dash;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- a2 := a3 + gap;
- if (extra > 0) then a2 := a2 + round(z*0.5);
- a3 := a2 + dot;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- end;
- end;
- J := J + 1;
- until (a3 >= a1);
- end;
- 20:
- end; { spread }
-
- {......................................................}
- procedure balance (lt : LineStyle; extra, T : integer);
- label 30;
- begin
- if (T = 0) then
- begin { only partial frame fits }
- if (useXaxis) then
- diagonal (a0, b0, a1, b1, fontindex)
- else
- diagonal (b0, a0, b1, a1, fontindex);
- goto 30; { exit }
- end;
- J := 0;
- s := float(b1 - b0)/float(a1 - a0);
- case lt of
- dashed : repeat a2 := a0 + J*frame - extra div 2;
- a3 := a2 + dash;
- if (J = 0) then a2 := a0;
- if (a3 > a1) then a3 := a1;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- end;
- J := J + 1;
- until (a3 >= a1);
- dotdash : repeat a2 := a0 + J*frame - extra div 2;
- a3 := a2 + dash;
- if (J = 0) then a2 := a0;
- if (a3 > a1) then a3 := a1;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- a2 := a3 + gap;
- a3 := a2 + dot;
- b2 := round(s*(a2-a0) + b0);
- b3 := round(s*(a3-a0) + b0);
- if (a3 <= a1) then
- begin
- if (useXaxis) then
- diagonal (a2, b2, a3, b3, fontindex)
- else
- diagonal (b2, a2, b3, a3, fontindex);
- end;
- end;
- J := J + 1;
- until (a3 >= a1);
- end;
- 30:
- end; { balance }
-
- {......................................................}
- function project (I : integer) : integer;
- var K : integer; { gives the projection of lengths onto axes }
- begin
- K := round(I*float(abs(a1-a0))/s);
- if K = 0 then K := 1;
- project := K;
- end;
- {......................................................}
- procedure setlengths (findex :integer);
- (* sets the "optimal" sizes for textured lines *)
- var penrad : integer;
- siz : VThickness;
- begin
- penrad := VFontTable[findex]^.PenSize;
- siz := VFontTable[findex]^.psize;
-
- Dotdot := penrad div siz; Dotgap := 6 * penrad;
- Dashdash := 6 * penrad; Dashgap := 6 * penrad;
- DDotdash := 6 * penrad; DDotgap := 4 * penrad;
- DDotdot := penrad div siz;
- end;
- {........................................}
- procedure setframesize;
- begin
- case line_type of { length of frame depends on type of broken line }
- solid : frame := 0;
- dotted : frame := gap + dot;
- dashed : frame := gap + dash;
- dotdash : frame := 2*gap + dot + dash;
- end;
- end;
-
- {.................................................}
- begin (* TylBrokenLine *)
- if ((x0 = x1) and (y0 = y1)) then
- begin
- diagonal (x0, y0, x1, y1, fontindex); { null line }
- goto 10;
- end;
-
- setlengths (fontindex);
-
- if (abs (y1-y0) > abs(x1-x0)) then { longer axis is used as base }
- begin
- useXaxis := false;
- a0 := y0; b0 := x0;
- a1 := y1; b1 := x1;
- end
- else
- begin
- useXaxis := true;
- a0 := x0; b0 := y0;
- a1 := x1; b1 := y1;
- end;
- { the distance between a0 and a1 is now greater than that between b0 and b1. }
-
- { redefine distances as integral units along axes }
- s := distance (float(a0),float(b0),float(a1),float(b1));
-
- case line_type of
- solid: ;
- dotted:
- begin
- gap := project(Dotgap);
- dot := project(Dotdot);
- end;
- dashed:
- begin
- gap := project(Dashgap);
- dash := project(Dashdash);
- end;
- dotdash:
- begin
- gap := project(DDotgap);
- dot := project(DDotdot);
- dash := project(DDotdash);
- end;
- end;
-
- { ensure direction of line is from smaller to
- larger along the longer axis }
- if (a0 > a1) then
- begin
- J := a0; a0 := a1; a1 := J;
- J := b0; b0 := b1; b1 := J;
- end;
-
- setframesize;
-
- a1ma0 := a1 - a0;
-
- { fit is the number of frames that fit in line }
- if (frame <> 0) then
- begin
- fit := (float(a1ma0) / float(frame));
- end
- else
- fit := 1.0;
-
- if (fit >= 1.0) then
- T := round (fit)
- else
- begin
- (* change frame elements (dot, dash, gap) since frame is too large *)
- case line_type of
- dotted : begin
- gap := gap - (frame - a1ma0);
- if (gap < dot) then
- begin
- goto 10; (* exit *)
- end;
- setframesize;
- end;
-
- dashed,
- dotdash : begin
- (* idea:decrease gap; if too small then shrink dash and refigure gap*)
- if ((frame - a1ma0) > (gap div 2)) then
- begin
- dash := round (dash * fit * 0.80);
- gap := round (gap * fit);
- setframesize;
- end;
- gap := gap - (frame - a1ma0);
- if (line_type = dotdash) then
- gap := gap div 2;
- if (gap < dot) then
- begin
- goto 10; (* exit *)
- end;
- setframesize;
- end;
- end; (* case *)
- T := 1; (* NOW it will fit *)
- end; (* else *)
-
-
- case line_type of
- solid : begin
- if (useXaxis) then
- diagonal (a0, b0, a1, b1, fontindex)
- else
- diagonal (b0, a0, b1, a1, fontindex);
- end;
-
- dotted : begin { dotted lines begin and end on a dot }
- if ((T*frame + dot) = a1ma0) then
- spread(dotted, 0, T)
- else if ((T*frame + dot) > a1ma0) then
- begin
- { gap := gap - ((T*frame+dot)-a1ma0);
- {}
- spread(dotted, a1ma0 - T*frame - dot, T);
-
- { spread(dotted, a1ma0 - (T-1)*frame - dot, T-1);
- {}
- end
- else
- spread(dotted, a1ma0 - T*frame - dot, T);
- end;
-
- dashed : begin
- { dashed lines begin and end on dash :
- the beginning and ending dashes are at least half
- the dash length long. }
- if ((T*frame + dash) = a1ma0) then
- spread(dashed, 0, T)
- else if ((T*frame + dash) > a1ma0) then
- balance(dashed, T*frame + dash - a1ma0, T)
- else spread(dashed, a1ma0 - T*frame - dash, T);
- end;
-
- dotdash : begin { if ending on a dash then beginning and ending
- dashes are half the dash length long - final
- dots are full dot length }
- if ((T*frame + dash) = a1ma0) then
- spread(dotdash, 0, T)
- else if ((T*frame + dash + gap + dot) = a1ma0) then
- spread(dotdash, 0, T)
- else if ((T*frame + dash) > a1ma0) then
- balance(dotdash, T*frame + dash - a1ma0, T)
- else if ((T*frame + dash + gap + dot) > a1ma0) then
- spread(dotdash, a1ma0 - T*frame - dash, T)
- else spread(dotdash, a1ma0 - T*frame - dash - gap - dot, T);
- end;
- end;
- 10:
- end;
-
-
-
- {-------------------------------------------------------}
- procedure clampthickness (var thic : VThickness);
- begin
- (* #### this is just a simple clamp
- really should be something like:
- while not (thic in set_of_appropriate_thicknesses) do
- modify thic and try again
- *)
- if (thic <= LoVThick ) then
- thic := LoVThick + 1;
- while ((not (thic in [1,2,3,4,5,6,7,8,9,10,11,12])) and
- (thic <= HiVThick)) do
- thic := thic + 1;
-
- if (thic > HiVThick) then
- thic := HiVThick;
- end;
-
- {----------------------------------------------------------}
- procedure slurclamp (var thic : ThickAryType; totpts : integer);
- (* this post-clamps the sampled thicknesses calculated over the
- whole of the spline *)
-
- var i : integer;
- oneseventh : integer;
- middle : integer;
- startval, endval: integer;
- deltaval, val, incrval, alpha, alphaincr: real;
-
- begin
- { $$ NOTE:: How does the ttspline interpolation of thicknesses
- compare to the below results?? Can we avoid having it done
- elsewhere and concentrate on it here?? }
-
- oneseventh := round (totpts / 7.0);
- for i := 1 to oneseventh do
- begin
- thic[i] := thic[1];
- end;
- for i := 6*oneseventh to totpts do
- begin
- thic[i] := thic[totpts];
- end;
-
- middle := round (totpts / 2.0);
- for i := 3*oneseventh to 4*oneseventh do
- begin
- thic[i] := thic[middle];
- end;
-
- startval := thic[oneseventh - 1];
- endval := thic[3*oneseventh + 1];
- deltaval := (2*(endval - startval))/(2*oneseventh);
- alphaincr := PI / (2 * oneseventh + 1);
- alpha := PI;
- val := float(startval);
- for i := oneseventh to (3*oneseventh - 1) do
- begin (* interpolate: ease in from minthick to middlethickness *)
- alpha := alpha + alphaincr;
- incrval := ((cos (alpha) + 1.0) / 2.0) * deltaval;
- val := val + incrval;
- thic[i] := round(val);
- end;
-
- startval := thic[4*oneseventh - 1];
- endval := thic[6*oneseventh + 1];
- deltaval := (2*(endval - startval))/(2*oneseventh);
- alphaincr := PI / (2 * oneseventh + 1);
- alpha := 0.0;
- val := float(startval);
- for i := (4*oneseventh + 1) to 6*oneseventh do
- begin (* ease out from middle thickness to min thick at far end *)
- alpha := alpha + alphaincr;
- incrval := ((cos (alpha) + 1.0) / 2.0) * deltaval;
- val := val + incrval;
- thic[i] := round(val);
- end;
- end;
-
- {-------------------------------------------------------}
- procedure layline (xl, yb, xr, yt, fontindex : integer;
- pattern : LineStyle; useVecfontOnly : boolean);
- var t: integer;
- begin
- if (xr < xl) then
- begin
- t := xr; xr := xl; xl := t;
- t := yb; yb := yt; yt := t;
- end;
-
- isetfont (VFontTable[fontindex]^.DVIFontNum);
-
- (* we may want to require using a vector font only,
- instead of a combination of vectors and TeX-rules.
- It may look better this way.
- *)
- if (useVecfontOnly) then
- begin
- tylBrokenLine (xl, yb, xr, yt, fontindex, pattern);
- end
- else
- begin (* be smart about the lines *)
- if ((xl = xr) and (yb = yt)) or
- ((xl <> xr) and (yb <> yt)) then (* Null or diagonal lines *)
- begin
- if (pattern = solid) then
- diagonal (xl, yb, xr, yt, fontindex)
- else
- tylBrokenLine (xl, yb, xr, yt, fontindex, pattern);
- end
- else
- begin
- { if (pattern = solid) then
- hvline (xl, yb, xr, yt, fontindex) (* make use of rules *)
- else
- USENORULES }
- tylBrokenLine (xl, yb, xr, yt, fontindex, pattern);
- end
- end;
-
- end;
-
-
-
- {------------------------------------------------------}
- procedure layAspline (thetype : SplineKind;
- isclosed : boolean;
- isanArc: boolean;
- domarks : integer;
- var cpts : ControlPoints;
- numpts : integer;
- thick: VThickness;
- vkind : VectKind;
- patt : LineStyle);
- const DontDoThicks = false;
- VectorsOnly = true;
- var pointList: SplineSegments;
- i, xs, ys : integer;
- tt1, tt2 : ThickAryType;
- F: VecIndex;
- begin
-
- clampthickness (thick);
- for i := 0 to (numpts + 3) do
- tt1[i] := thick;
-
- (* do any marks if necessary to show the control points *)
- if (domarks > 0) then
- begin
- F := GetVectFont (domarks, VKCirc);
- isetfont (VFontTable[F]^.DVIFontNum);
- for i := 1 to numpts do
- begin
- Tyldot (cpts[i,1], cpts[i,2]);
- end;
- end;
-
- drawSpline (thetype, isclosed, isanArc, patt,
- numpts, cpts, pointList, DontDoThicks, tt1, tt2);
-
-
- F := GetVectFont (thick, vkind);
- xs := pointList[1, 1];
- ys := pointList[1, 2];
-
- for i := 2 to lastPoint do
- begin
- layline (xs, ys, pointList[i, 1], pointList[i, 2], F, patt, VectorsOnly);
- xs := pointList[i, 1];
- ys := pointList[i, 2];
- end;
- if (isclosed) then (* complete the motion *)
- layline (pointList[lastPoint,1], pointList[lastPoint,2],
- pointList[1,1], pointList[1,2], F, patt, VectorsOnly);
- end;
-
-
- {-----------------------------------------------------}
- procedure layNspline (thetype : SplineKind;
- isclosed : boolean;
- isitaslur : boolean;
- domarks : integer;
- var cpts : ControlPoints;
- numpts : integer;
- var thickmatrix : ThickAryType;
- vkind : VectKind;
- patt : LineStyle);
- const NotAnArc = false;
- DoThicksToo = true;
- VectorsOnly = true;
- var pointList: SplineSegments;
- i, xs, ys : integer;
- ts : VThickness;
- tt : ThickAryType;
- F : VecIndex;
- begin
- (* do any marks if necessary to show the control points *)
- if (domarks > 0) then
- begin
- F := GetVectFont (domarks, VKCirc);
- isetfont (VFontTable[F]^.DVIFontNum);
- for i := 1 to numpts do
- begin
- Tyldot (cpts[i,1], cpts[i,2]);
- end;
- end;
-
- drawSpline (thetype, isclosed, NotAnArc, patt,
- numpts, cpts, pointList,
- DoThicksToo, thickmatrix, tt);
- if ((isitaslur) and (not skiptsclamp)) then
- begin
- slurclamp(tt, lastPoint); (* which kind of clamping to use *)
- end;
-
- xs := pointList[1, 1];
- ys := pointList[1, 2];
- ts := tt[1];
-
- for i := 2 to lastPoint do
- begin
- clampthickness (ts);
- F := GetVectFont (ts, vkind);
- layline (xs, ys, pointList[i, 1], pointList[i, 2], F, patt, VectorsOnly);
- xs := pointList[i, 1];
- ys := pointList[i, 2];
- ts := tt[i];
- end;
- if (isclosed) then
- begin
- ts := tt[lastPoint];
- clampthickness(ts);
- F := GetVectFont (ts, vkind);
- layline (pointList[lastPoint,1], pointList[lastPoint,2],
- pointList[1,1], pointList[1,2], F, patt, VectorsOnly);
- end;
- end;
-
-
-
- {-----------------------------------------------------}
- procedure TylBeam (* fromx, fromy, tox, toy: ScaledPts;
- staffsize : integer; kind : BeamKind *);
-
- begin
-
- end; (* TylBeam *)
-
-
- {-------------------------------------------------------}
- procedure TylLine (* xl, yb, xr, yt: ScaledPoints;
- thickness: VThickness;
- vec: VectKind; patt : LineStyle *);
- const dontCare = false;
- var findex: VecIndex;
- begin
- clampthickness (thickness);
- findex := GetVectFont (thickness, vec);
- layline (xl, yb, xr, yt, findex, patt, dontCare);
- end;
-
-
- {-----------------------------------------------------}
- procedure TylThickThinSpline (* thetype : SplineKind; isclosed : boolean;
- var KnotArray: ControlPoints;
- var ThikThinAry: ThickAryType;
- numknots: integer;
- vec: VectKind;
- patt : LineStyle; domarks : integer *);
- const NotAnArc = false;
- begin
- layNspline (thetype, isclosed, NotAnArc, domarks, KnotArray, numknots,
- ThikThinAry, vec, patt);
- end;
-
- {----------------------------------------------------}
- procedure TylSpline (* thetype : SplineKind; isclosed : boolean;
- var KnotArray: ControlPoints; numknots: integer;
- thick: VThickness; vec: VectKind; patt : LineStyle; domarks : integer*);
- const NotAnArc = false;
- begin
- layAspline (thetype, isclosed, NotAnArc, domarks, KnotArray, numknots,
- thick, vec, patt);
- end;
-
- {-----------------------------------------------------}
- procedure TylTieSlur (* KnotArray: ControlPoints;
- numknots: integer;
- minthick, maxthick: VThickness *);
- const ItsASlur = true;
- NotClosed = false;
- var ourttarray : ThickAryType;
- one7th : real;
- val : VThickness;
- begin
-
- clampthickness (minthick);
- clampthickness (maxthick);
- if (numknots <> 5) then
- writeln ('TieSlur needs 5 control points ');
- one7th := 1.0/7.0;
- val := round (one7th * (maxthick - minthick));
- ourttarray[1] := minthick;
- ourttarray[2] := minthick + val;
- ourttarray[3] := maxthick;
- ourttarray[4] := minthick + val;
- ourttarray[5] := minthick;
-
- layNspline (CATROM, NotClosed, ItsASlur, 0, KnotArray, numknots, ourttarray,
- VKCirc, solid);
- end;
-
-
- {-------------------------------------------------------}
- procedure doTylArc (* iscircle : boolean;
- var apts : ControlPoints;
- numknots : integer;
- thick : VThickness;
- vec : VectKind;
- patt : LineStyle *);
-
- const ItsAnArc = true;
- begin
-
- layAspline (BSPL, iscircle, ItsAnArc, 0, apts, numknots, thick, vec, patt);
- end;
-
- {-----------------------------------------------------------}
- procedure TylArc (* radius : ScaledPts; centx, centy : ScaledPts;
- firstangle, secondangle : integer;
- thick : VThickness; vec : VectKind; patt : LineStyle *);
- var apts : ControlPoints;
- numknots : integer;
- iscircle : boolean;
- begin
- iscircle := (firstangle = secondangle);
- if iscircle then
- begin
- { maxspan := round ((360.0 / 16.0) * DEGTORAD * radius);
- {}
- defineCircleCpts (radius, centx, centy, apts, numknots);
- end
- else
- begin
- { maxspan := round ((abs (secondangle - firstangle) / 16.0) * DEGTORAD * radius);
- { }
- definearcpts (radius, centx, centy,
- firstangle, secondangle, apts, numknots);
- end;
-
- doTylArc (iscircle, apts, numknots, thick, vec, patt);
-
- end;
-
- {-----------------------------------------------------------}
- procedure TylLabel (* xpos, ypos : ScaledPts;
- fontstyle : integer;
- phrase : charstring;
- phraselen : integer *);
- var findex : integer;
- c : integer;
- spaceover : integer;
-
- begin
- if ((fontstyle < 1) or (fontstyle > MAXLABELFONTS)) then
- begin
- complain (ERRREALBAD);
- writeln(logfile,'Unexpected bad fontstyle in TylLabel: ',fontstyle:0,'?');
- jumpout;
- end;
- findex := GetLabFont (fontstyle);
- isetpos (xpos, ypos);
- IPUSH;
- isetfont (LFontTable[findex]^.DVIFontNum);
- spaceover := LFontTable[findex]^.spacewidth;
- for c := 1 to phraselen do
- begin
- if (phrase[c] <> xchr[32]) then
- begin
- cmd1byte (SET1);
- cmd1byte (xord[ phrase[ c ]]);
- end
- else
- begin (* move over *)
- cmd1byte (RIGHTLEFT + 2); (* assume distance is less than 3 bytes *)
- cmdSigned (spaceover, 3);
- end;
- end;
- IPOP;
- end;
-
-
- (* && start dvidvi section *)
- {-----------------------------------------------------}
- procedure initialize;
- var
- i: integer;
- begin
- for i := 0 to 31 do
- xchr[i] := '?';
- xchr[32] := ' ';
- xchr[33] := '!';
- xchr[34] := '"';
- xchr[35] := '#';
- xchr[36] := '$';
- xchr[37] := '%';
- xchr[38] := '&';
- xchr[39] := '''';
- xchr[40] := '(';
- xchr[41] := ')';
- xchr[42] := '*';
- xchr[43] := '+';
- xchr[44] := ',';
- xchr[45] := '-';
- xchr[46] := '.';
- xchr[47] := '/';
- xchr[48] := '0';
- xchr[49] := '1';
- xchr[50] := '2';
- xchr[51] := '3';
- xchr[52] := '4';
- xchr[53] := '5';
- xchr[54] := '6';
- xchr[55] := '7';
- xchr[56] := '8';
- xchr[57] := '9';
- xchr[58] := ':';
- xchr[59] := ';';
- xchr[60] := '<';
- xchr[61] := '=';
- xchr[62] := '>';
- xchr[63] := '?';
- xchr[64] := '@';
- xchr[65] := 'A';
- xchr[66] := 'B';
- xchr[67] := 'C';
- xchr[68] := 'D';
- xchr[69] := 'E';
- xchr[70] := 'F';
- xchr[71] := 'G';
- xchr[72] := 'H';
- xchr[73] := 'I';
- xchr[74] := 'J';
- xchr[75] := 'K';
- xchr[76] := 'L';
- xchr[77] := 'M';
- xchr[78] := 'N';
- xchr[79] := 'O';
- xchr[80] := 'P';
- xchr[81] := 'Q';
- xchr[82] := 'R';
- xchr[83] := 'S';
- xchr[84] := 'T';
- xchr[85] := 'U';
- xchr[86] := 'V';
- xchr[87] := 'W';
- xchr[88] := 'X';
- xchr[89] := 'Y';
- xchr[90] := 'Z';
- xchr[91] := '[';
- xchr[92] := '\';
- xchr[93] := ']';
- xchr[94] := '^';
- xchr[95] := '_';
- xchr[96] := '`';
- xchr[97] := 'a';
- xchr[98] := 'b';
- xchr[99] := 'c';
- xchr[100] := 'd';
- xchr[101] := 'e';
- xchr[102] := 'f';
- xchr[103] := 'g';
- xchr[104] := 'h';
- xchr[105] := 'i';
- xchr[106] := 'j';
- xchr[107] := 'k';
- xchr[108] := 'l';
- xchr[109] := 'm';
- xchr[110] := 'n';
- xchr[111] := 'o';
- xchr[112] := 'p';
- xchr[113] := 'q';
- xchr[114] := 'r';
- xchr[115] := 's';
- xchr[116] := 't';
- xchr[117] := 'u';
- xchr[118] := 'v';
- xchr[119] := 'w';
- xchr[120] := 'x';
- xchr[121] := 'y';
- xchr[122] := 'z';
- xchr[123] := '{';
- xchr[124] := '|';
- xchr[125] := '}';
- xchr[126] := '~';
- for i := 127 to 255 do
- xchr[i] := '?';
- for i := 0 to 127 do
- xord[chr(i)] := 32;
- for i := 32 to 126 do
- xord[xchr[i]] := i;
- initallspline;
- initVnMnLtables;
- multifigure := 0;
- pgfigurenum := 0;
- TotBytesWritten := 0;
- ourq := 0;
- specstart := 0;
- currpagenum := 0;
- newbackptr := (-1);
- oldbackptr := (-1);
- ourfontnum := (-1); (* undefined *)
- origTexfont := (-1);
- ourpushdepth := 0;
- FTBDs := 0;
- InitDVIBuf;
- nf := 0;
- inpostamble := false;
- didnewfonts := false;
- maxpages := 10000;
- sysdependent;
- s := 0;
- skiptsclamp := false;
- ErrorOccurred := false;
- end;
-
-
-
- procedure inputln (var buffer : strng);
- var
- k: 0..ARRLIMIT;
- begin
-
- flush(output);
-
- if eoln(input) then
- readln(input);
- k := 1;
- while (k < ARRLIMIT) and (not eoln(input)) do
- begin
- buffer.str[k] := input^;
- k := k + 1;
- get(input)
- end;
- buffer.str[k] := ' ';
- buffer.len := k - 1;
- end;
-
- function revindex (st : strng; let : char) : integer;
- label 2;
- var posit,i : integer;
- begin
- posit := 0;
- for i := st.len downto 1 do
- begin
- if (st.str[i] = let) then
- begin
- posit := i;
- goto 2;
- end;
- end;
- 2:
- revindex := posit;
- end;
-
-
- procedure stripblanks (var st : strng);
- var i,j,k: integer;
- temp : charstring;
- begin
- j := 1;
- i := 1;
- while ((i <= st.len) and
- ((st.str[i] = ' ') or (st.str[i] = xchr[HT]))) do
- begin
- j := j + 1;
- i := i + 1;
- end;
-
- (* j now points to the first non-blank character in st.str *)
- i := 1;
- for k := j to st.len do
- begin
- if ((st.str[k] <> ' ') and (st.str[k] <> xchr[HT])) then
- begin
- temp[i] := st.str[k];
- i := i + 1;
- end;
- end;
- (* now copy it back *)
- if (i <> 1) then
- begin (* there was blankspace *)
- for k := 1 to (i- 1) do
- st.str[k] := temp[k];
- st.len := i - 1;
-
- st.str[i] := chr(32); (* end of string *)
-
- end;
- end;
-
-
- {-----------------------------------------------------}
- procedure AskandOpenFiles;
- var isok : boolean;
- i : integer;
- rp : integer;
- tempname : strng;
- begin
- isok := false;
- while (not isok) do
- begin
- write (' DVI-input File Name: ');
- inputln (dvifname);
- stripblanks (dvifname);
-
- rp := revindex (dvifname, '.');
- if (rp = 0) then
- begin
- (* add a ".dvi" extension *)
- i := dvifname.len;
- dvifname.str[i + 1] := '.';
- dvifname.str[i + 2] := 'd';
- dvifname.str[i + 3] := 'v';
- dvifname.str[i + 4] := 'i';
- dvifname.len := i + 4;
- end;
- if (not opendvifile) then
- begin
- isok := false; (* it is empty *)
- writestrng(dvifname,false);
- writeln(': Empty File?? Try another name.');
- end
- else
- isok := true;
- end; (* while *)
-
- (* and ask for the name of the output file *)
- (* default it to be the same prefix, but with a ".tyl" suffix *)
- strcopy (dvifname.str, outname.str, dvifname.len);
- outname.len := dvifname.len;
- rp := revindex (outname, '.');
- i := rp - 1;
- outname.str[i + 1] := '.';
- outname.str[i + 2] := 't';
- outname.str[i + 3] := 'y';
- outname.str[i + 4] := 'l';
- outname.len := i + 4;
-
- writeln (' DVI-output File Name :');
- write('(different than input name)[default of ');
- writestrng (outname,false);
- write(']');
- inputln (tempname);
- if (tempname.len > 1) then
- begin (* a filename was typed in *)
-
- strcopy (tempname.str, outname.str, tempname.len);
- end;
-
- openoutputfile;
- E_O_F
- else
- echo "will not over write ./src/textyl.pas.ag"
- fi
- chmod 644 ./src/textyl.pas.ag
- if [ `wc -c ./src/textyl.pas.ag | awk '{printf $1}'` -ne 27504 ]
- then
- echo `wc -c ./src/textyl.pas.ag | awk '{print "Got " $1 ", Expected " 27504}'`
- fi
- if `test ! -s ./src/textyl.pas.af`
- then
- echo "writing ./src/textyl.pas.af"
- cat > ./src/textyl.pas.af << 'E_O_F'
- procedure gettransforms (var sc1, sc2, r : real;
- var tr1, tr2 : integer);
- label 22;
- var i : integer;
- dun : boolean;
- begin
- sc1 := 1.0; sc2 := 1.0;
- tr1 := 0; tr2 := 0;
- r := 0.0;
- i := parsposit - 1;
- if (i < 1) then
- begin
- goto 22; (* exit with defaults *)
- end;
- dun := false;
- while ((i < parsmax) and not dun) do
- begin
- if (isaletter(parsearray[i])) then
- begin
- if ((parsearray[i] = xord['t']) or
- (parsearray[i] = xord['T'])) then
- begin
- if (isdelimiter(parsearray[i+1]) and
- isdelimiter(parsearray[i-1])) then
- begin (* get transform parameters *)
- sc1 := getnumber / 100.0;
- sc2 := getnumber / 100.0;
- tr1 := getnumber;
- tr2 := getnumber;
- r := float(getnumber); (* degrees about primitive center *)
- if (r < 0.0) then
- r := r + 360.0;
- dun := true;
- end;
- end;
- end;
- i := i + 1;
- end; (* while *)
- 22:
- end; (* gettransforms *)
-
- {__________________________________________________________________}
- function findmarker (markset : charset) : integer;
- label 1111;
- var i, sym : integer;
- dun : boolean;
- begin
- i := parsposit - 1;
- sym := EMPTY;
- if (i < 1) then
- goto 1111;
- dun := false;
- while ((i < parsmax) and not dun) do
- begin
- if (isaletter(parsearray[i])) then
- begin
- if (xchr[ parsearray[i] ] in markset) then
- begin
- if (isdelimiter (parsearray[i+1]) and
- isdelimiter (parsearray[i-1])) then
- begin
- sym := xord[tolowercase(xchr[parsearray[i]])];
- dun := true;
- end;
- end;
- end; (* if a letter *)
- i := i + 1;
- end; (* while *)
- 1111: findmarker := sym;
- end;
-
-
-
- function findscale : integer;
- begin
- findscale := findmarker(['s','S','p','P','m','M']);
- end;
-
- function findvectkind : integer;
- begin
- findvectkind := findmarker(['c','C','h','H','v','V']);
- end;
-
- function findlinestyle : integer;
- begin
- findlinestyle := findmarker(['l','L']);
- end;
-
- function findbeamkind : integer;
- begin
- findbeamkind := findmarker(['r','R','g','G']);
- end;
-
- function findsplinekind : integer;
- begin
- findsplinekind := findmarker(['b','B','i','I','k','K','d','D']);
- end;
-
- function findsplclosure : integer;
- begin
- findsplclosure := findmarker(['o','O','u','U']);
- end;
-
- function findatsign : integer;
- begin
- findatsign := findmarker(['@']);
- end;
-
- function finddotmark : integer;
- begin
- finddotmark := findmarker(['x','X']);
- end;
-
- function findfigdimens : integer;
- begin
- findfigdimens := findmarker(['w','W']);
- end;
-
- function findfitsizes : integer;
- begin
- findfitsizes := findmarker(['f','F']);
- end;
-
-
- {_________________________________________________}
- function thescaleof (scal : integer) : real;
- begin
- if (scal = xord['s']) then
- thescaleof := 1 * magfactor
- else if (scal = xord['p']) then
- thescaleof := SPPERPT * magfactor
- else if (scal = xord['m']) then
- thescaleof := SPPERMM * magfactor
- else if (scal = EMPTY) then
- thescaleof := SPPERPT * magfactor;
- end;
-
-
- function thevectorof (vkin : integer) : VectKind;
- begin
- if (vkin = xord['c']) then
- thevectorof := VKCirc
- else if (vkin = xord['v']) then
- thevectorof := VKVert
- else if (vkin = xord['h']) then
- thevectorof := VKHort
- else if (vkin = EMPTY) then
- thevectorof := VKCirc;
- end;
-
- function thestyleof (linest : integer) : LineStyle;
- begin
- if ((linest > 3) or
- (linest < 0)) then linest := 0;
- case linest of
- 0 : thestyleof := solid;
- 1 : thestyleof := dotted;
- 2 : thestyleof := dashed;
- 3 : thestyleof := dotdash;
- end;
- end;
-
-
-
-
- (* -----!!!!!!!!!!!! HandleSpecials !!!!!!!!!!!!!------ *)
- begin
- tylnam := 'tyl';
- beginfigurenam := 'beginfigure';
- endfigurenam := 'endfigure';
- linenam := 'line';
- splinenam := 'spline';
- ttsplnam := 'ttspline';
- beamnam := 'beam';
- tieslurnam := 'tieslur';
- arcnam := 'arc';
- labelnam := 'label';
- paramnam := 'param';
- usingstream := true; (* getting bytes from dvifile *)
-
- specstart := DVIMark - (specnum - 239 + 1) - 1;
-
- ourxpos := h; ourypos := v; (* note the global DVI (h,v) coords *)
- i := 1;
-
- b := Dget1byte; (* prime the reading scheme *)
- gotten := (specnum - 239 + 1);
-
- while (isaspace(b)) do
- b := nextpbyte;
-
- let := getletter;
- while (let <> ' ') do (* get the name of the system --- Hopefully 'tyl' *)
- begin
- sysnam.str[i] := tolowercase(let);
- sysnam.len := i;
- i := i + 1;
- let := getletter;
- end;
-
- sysnam.str[i] := chr(32); (* end of string *)
-
- if (not streq (sysnam.str, tylnam, 3)) then (* TeXtyl doesnt know about this special *)
- begin
- write (logfile,'The special: ');
- writestrng(sysnam,true);
- writeln(logfile,' is not tyl-able. Skipping...');
- while (gotten < numpbytes) do
- b := nextpbyte;
- goto 888;
- end;
-
- (* OTHERWISE: all is okay. Lets look for a primitive to tyl *)
-
- while (isdelimiter(b)) do
- begin
- b := nextpbyte;
- end;
- i := 1;
- let := getletter; {xchr[b];}
- while (not (isdelimiter(xord[let]))) do (* get the name of the primitive *)
- begin
- nam.str[i] := tolowercase(let);
- nam.len := i;
- i := i + 1;
- let := getletter;
- end;
-
- nam.str[i] := chr(32); (* end of string *)
-
-
- let := xchr[b];
-
- (* Now, fill the parse array with bytes so that we can get
- the given parameters, and infer the defaulted params *)
-
- parsmax := min (PARSLEN, ((numpbytes - gotten) + 1));
-
- if (parsmax > 1) then
- begin
- parsearray[1] := xord[' ']; (* we need this *)
- parsearray[2] := b; (* start filling *)
- for i := 3 to parsmax do
- begin (* fill rest *)
- parsearray[i] := nextpbyte;
- end;
- parsposit := 1;
- usingstream := false; (* now we look at bytes in parse array *)
- b := nextpbyte; (* start it *)
- end
- else
- begin
- usingstream := true;
- parsposit := -1; (* undefined *)
- end;
-
- (* --- BEGINFIGURE ---- *)
- if streq(nam.str, beginfigurenam, 3) then
- begin
- multifigure := multifigure + 1;
- i := findscale;
- SPscale := thescaleof (i);
-
- gettransforms (sx100, sy100, rot, transx, transy);
- (* store all the primitives on pageitems, and dont output
- them until we get a endfigure. this way, we can take
- care of dealing with all the primitives according to
- some global tranformation for the whole figure *)
- pi := NewItem (Afigure);
- with pi^ do
- begin
- figtheta := rot;
- fsx := sx100; fsy := sy100;
- fdx := round (transx * SPscale);
- fdy := round (transy * SPscale);
- depthnumber := multifigure; (* we're at a new level *)
- i := findfigdimens;
- if (i <> EMPTY) then
- begin
- preWid := round (getnumber * SPscale);
- preHt := round (getnumber * SPscale);
- end;
- i := findfitsizes;
- if (i <> EMPTY) then
- begin
- postWid := round (getnumber * SPscale);
- postHt := round (getnumber * SPscale);
- end;
- end; (* with *)
- BackupInBuf (DVIMark - specstart);
- pushItem (multifigure - 1, pi);
- goto 888;
- end;
- (* ---- ENDFIGURE ---- *)
- if streq(nam.str, endfigurenam, 3) then
- begin
- multifigure := multifigure - 1;
- if (multifigure < 0) then
- begin
- complain (ERRBAD);
- write(logfile,'Warning: Too many "endfigure"s !');
- multifigure := 0;
- end;
- BackupInBuf (DVIMark - specstart);
-
- if (multifigure = 0) then
- begin
- (* go do our set of figures (within figures...) *)
- figurehandle (pageitems, pageitems, 1);
- dispose (pageitems); (* ### should maybe garbage collect here *)
- pageitems := nil;
- end; (* if *)
- goto 888;
- end;
-
- (* --- LINE --- *)
- if streq(nam.str, linenam, 3) then
- begin
- i := findscale;
- SPscale := thescaleof(i);
-
- gettransforms (sx100, sy100, rot, transx, transy);
- thk := getnumber; (* get the vector thickness *)
- if (thk < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'?? Thickness not found. Setting to 1');
- thk := 1;
- end;
- i := findvectkind;
- vk := thevectorof (i);
-
- i := findlinestyle;
- if (i <> EMPTY) then
- patt := thestyleof (getnumber)
- else
- patt := solid;
-
- x1 := round (getnumber * SPscale);
- y1 := round (getnumber * SPscale);
- x2 := round (getnumber * SPscale);
- y2 := round (getnumber * SPscale);
-
- minx := min (x1, x2);
- maxx := max (x1, x2);
- miny := min (y1, y2);
- maxy := max (y1, y2);
-
- BackupInBuf (DVIMark - (specstart));
- cmd1byte (OURFONTFLAG);
- linehandle (multifigure, SPscale, x1, y1, x2, y2, 0, 0, thk, vk, patt,
- minx, maxx, miny, maxy,
- transx, transy, sx100, sy100, rot);
- end (* line *)
- (* ---- THE SPLINES ---- *)
- else if (streq(nam.str, splinenam, 3) or
- streq(nam.str, ttsplnam,3)) then
- begin
- i := findscale;
- SPscale := thescaleof (i);
-
- gettransforms (sx100, sy100, rot, transx, transy);
-
- if streq(nam.str, splinenam, 3) then
- begin
- thk := getnumber;
- if (thk < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Spline Thickness not found. Setting to 1');
- thk := 1;
- end;
- end;
- i := findvectkind;
- vk := thevectorof (i);
-
- i := findlinestyle;
- if (i <> EMPTY) then
- patt := thestyleof (getnumber)
- else
- patt := solid;
-
- i := findsplinekind;
- if (i = xord['b']) then
- splinetype := BSPL
- else if (i = xord['i']) then
- splinetype := INTBSPL
- else if (i = xord['k']) then
- splinetype := CATROM
- else if (i = xord['d']) then
- splinetype := CARD
- else if (i = EMPTY) then
- splinetype := CATROM;
-
- i := findsplclosure;
- if (i = xord['o']) then
- isclosedspline := true
- else if (i = xord['u']) then
- isclosedspline := false
- else if (i = EMPTY) then
- isclosedspline := false;
-
- i := finddotmark;
- if (i = xord['x']) then
- markdiam := getnumber
- else if (i = EMPTY) then
- markdiam := 0;
-
- numknots := min (getnumber, MAXCTLPTS);
- if (numknots < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Number of spline/ttspline knot points not found. Setting to 1');
- numknots := 1;
- end;
-
- minx := TWO24; miny := TWO24;
- maxx := -TWO24; maxy := -TWO24;
-
- for i := 0 to (numknots + 3) do
- begin
- cpts[i,1] := 0;
- cpts[i,2] := 0;
- end; (* for *)
-
- for i := 1 to numknots do
- begin
- x1 := round (getnumber * SPscale);
- cpts[i,1] := x1;
- if (x1 < minx) then
- minx := x1;
- if (x1 > maxx) then
- maxx := x1;
- y1 := round (getnumber * SPscale);
- cpts[i,2] := y1;
- if (y1 < miny) then
- miny := y1;
- if (y1 > maxy) then
- maxy := y1;
- end; (* for *)
-
- if streq(nam.str, ttsplnam, 3) then
- begin
- for i := 1 to numknots do
- begin
- TTary[i] := getnumber;
- end;
- end;
-
- BackupInBuf (DVIMark - (specstart));
- cmd1byte (OURFONTFLAG);
-
- if streq(nam.str, splinenam, 3) then
- splinehandle (multifigure, SPscale, splinetype, isclosedspline,
- markdiam, cpts, numknots,
- 0, 0, thk, vk, patt, minx, maxx, miny, maxy,
- transx, transy, sx100, sy100, rot)
- else
- ttsplhandle (multifigure, SPscale, splinetype, isclosedspline,
- markdiam, cpts, TTary, numknots,
- 0, 0, vk, patt, minx, maxx, miny, maxy,
- transx, transy, sx100, sy100, rot);
- end (* splines *)
- (* --- BEAMS ---- *)
- else if streq(nam.str, beamnam, 4) then
- begin
- i := findscale;
- SPscale := thescaleof (i);
-
- (* no transforms *)
-
- siz := getnumber; (* the staffsize *)
- i := findbeamkind;
- if (i = xord['g']) then
- bk := grace
- else if (i = xord['r']) then
- bk := regular
- else if (i = EMPTY) then
- bk := regular;
-
- x1 := round (getnumber * SPscale);
- y1 := round (getnumber * SPscale);
- x2 := round (getnumber * SPscale);
- y2 := round (getnumber * SPscale);
-
- BackupInBuf (DVIMark - (specstart));
- cmd1byte (OURFONTFLAG);
-
- beamhandle (multifigure, siz, bk, x1, y1, x2, y2);
- end (* beam *)
- (* ---- TIES AND SLURS ---- *)
- else if streq(nam.str, tieslurnam, 3) then
- begin
- i := findscale;
- SPscale := thescaleof (i);
-
- minthk := getnumber;
- if (minthk < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Tie/Slur Min Thickness not found. Setting to 1');
- minthk := 1;
- end;
-
- maxthk := getnumber;
- if (maxthk < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Tie/Slur MaxThickness not found. Setting to 1');
- maxthk := 1;
- end;
-
- numknots := min (getnumber, MAXCTLPTS);
- if (numknots < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Tie/Slur Number of knot points not found. Setting to 1. Should be 5');
- numknots := 1;
- end;
- for i := 1 to numknots do
- begin
- cpts[i,1] := round (getnumber * SPscale);
- cpts[i,2] := round (getnumber * SPscale);
- end; (* for *)
- BackupInBuf (DVIMark - (specstart));
- cmd1byte (OURFONTFLAG);
-
- tieslurhandle (multifigure, cpts, numknots, minthk, maxthk);
- end (* ties and slurs *)
- (* --------- ARCS and CIRCLES --------- *)
- else if streq (nam.str, arcnam, 3) then
- begin
- i := findscale;
- SPscale := thescaleof (i);
-
- gettransforms (sx100, sy100, rot, transx, transy);
-
- thk := getnumber;
- if (thk < 1) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Arc Thickness not found. Setting to 1');
- thk := 1;
- end;
- i := findvectkind;
- vk := thevectorof (i);
-
- i := findlinestyle;
- if (i <> EMPTY) then
- patt := thestyleof (getnumber)
- else
- patt := solid;
-
- radius := round (getnumber * SPscale);
- if (radius = 0) then
- radius := round(1 * SPscale);
- i := findatsign;
- if (i <> EMPTY) then
- begin
- x2 := round (getnumber * SPscale);
- y2 := round (getnumber * SPscale);
- end
- else
- begin
- x2 := 0; y2 := 0; (* assume center at origin *)
- end;
-
- ang1 := getnumber;
- if (abs(ang1) > 360) then
- ang1 := ang1 mod 360;
- ang2 := getnumber;
- if (abs(ang2) > 360) then
- ang2 := ang2 mod 360;
-
- minx := TWO24; miny := TWO24;
- maxx := -TWO24; maxy := -TWO24;
-
- if (ang1 = ang2) then
- begin (* a circle *)
- defineCircleCpts (radius,x2,y2, cpts, numknots);
- end
- else
- begin (* a real arc *)
- definearcpts (radius, x2,y2, ang1, ang2, cpts, numknots);
- end;
-
- for i := 1 to numknots do
- begin
- x1 := cpts[i,1];
- if (x1 < minx) then
- minx := x1;
- if (x1 > maxx) then
- maxx := x1;
-
- y1 := cpts[i,2];
- if (y1 < miny) then
- miny := y1;
- if (y1 > maxy) then
- maxy := y1;
- end; (* for *)
-
- BackupInBuf (DVIMark - (specstart));
- cmd1byte (OURFONTFLAG);
-
- arccirclehandle (multifigure, SPscale, x2, y2,
- radius, ang1, ang2,
- cpts, numknots,
- 0, 0, thk, vk, patt, minx, maxx, miny, maxy,
- transx, transy, sx100, sy100, rot)
-
- end (* arc and circle *)
- (* ---------- LABELS --------------*)
- else if streq (nam.str, labelnam, 3) then
- begin
- i := findscale;
- SPscale := thescaleof (i);
-
- style := getnumber; (* font style number *)
- if ((style < 1) or (style > MAXLABELFONTS)) then
- begin
- complain (ERRBAD);
- writeln(logfile,'Label style bad? Setting to Style 1');
- style := 1;
- end;
-
- x1 := round (getnumber * SPscale);
- y1 := round (getnumber * SPscale);
-
- let := getletter;
- while (let <> '"') do
- begin
- let := getletter;
- end;
- i := 0;
- let := getanything; (* get next letter or whatever *)
- while (let <> '"') do
- begin (* get the label phrase *)
- i := i + 1;
- phrase.str[i] := let;
- let := getanything; (* getletter;*)
- end;
-
- phrase.str[i+1] := chr(32);
-
- phrase.len := i;
-
- BackupInBuf (DVIMark - specstart);
- cmd1byte (OURFONTFLAG);
- labelhandle (multifigure, SPscale, x1, y1, 0, 0, style, phrase, 0, 0);
- end (* label *)
-
- (* --------- INTERNAL PARAM -------*)
- else if streq (nam.str, paramnam, 3) then
- begin
- i := getnumber; (* addressable param number *)
-
- begin
- writeln (logfile,' I do not know what internal parameter #',i:0,' is');
- end; (* else *)
- BackupInBuf (DVIMark - (specstart));
- end (* Internal param *)
-
- (* ============== NONE OF THE ABOVE ============== *)
- else
- begin
- complain (ERRNOTBAD);
- write (logfile,'Sorry, I don''t know how to tyl ');
- writestrng (nam,true);
-
- while (gotten < numpbytes) do
- begin
- b := nextpbyte;
- end;
- end;
- 888:
- (* make sure that we used up all the bytes in this special *)
- if (gotten < numpbytes) then
- begin
- while (gotten < numpbytes) do
- begin (* slurp up excess *)
- b := Dgrabbyte;
- gotten := gotten + 1;
- end;
- end; (* if *)
- end; (* mainhandlespecials *)
-
-
- (* ==================================================
-
- The routines below assume coordinates are already in
- 4th Quadrant DVI-space
-
- =====================================================*)
-
-
-
- {-----------------------------------------------------}
- (* returns 0 if dy.dx not in font
- 1 if ok
- 2 if ok and caller should use two of the "code"s
- coding scheme requires 0<= [dx, dy] <= 16
- AND that max(dx, abs(dy)) is in [0,1,2,4,8,16]
- *)
- function outvector (dx, dy : integer; var code : integer) : integer;
- label 99;
- var c : integer;
- result : integer;
- begin
- if (dx < 0) then
- begin
- outvector := 0;
- goto 99;
- end;
-
- result := 0; (* init for potential failure *)
- code := (-1);
- if (dy < 0) then
- begin
- c := 160 + dy + dx - 9*max (dx, -dy);
- end
- else
- begin
- c := 160 + dy - dx - 7*max (dx, dy);
- end;
-
- (* here translate to OUR coding scheme
- and return the correct number
- this is needed because "c" thinks the char range
- is 0 to 160, while we have only 128 chars *)
-
- if (c = 0) then (* special cases *)
- begin
- code := 63;
- result := 2;
- end
- else if (c = 64) then
- begin
- code := 95;
- result := 2;
- end
- else
- begin (* regular ones *)
- result := 1; (* just one char is fine *)
- if (c in [1..63]) then
- code := c - 1
- else if (c in [80..112]) then
- code := c - 17
- else if (c in [120..136]) then
- code := c - 24
- else if (c in [140..148]) then
- code := c - 27
- else if (c in [150..154]) then
- code := c - 28
- else if (c = 160) then
- code := 127; (* c - 33 *)
- end;
- 99:
- outvector := result;
- end;
-
-
-
- (* take care of a Manhattan (horizontal /vertical) line *)
- {----------------------------------------------------------}
- procedure hvline (lx, by, rx, ty, fontindex : integer);
- var t, rth, x, y, width, height : integer;
- begin
- rth := VFontTable[fontindex]^.PenSize; (* thickness of vector in sp *)
- if (lx = rx) then
- begin (* Vertical line *)
- if (ty > by) then
- begin
- t := by; by := ty; ty := t; (* swap *)
- end;
- x := round (lx - (rth / 2.0));
- y := by;
- width := rth;
- height := by - ty;
- end
- else
- begin (* Horizontal line *)
- if (ty < by) then
- begin
- t := by; by := ty; ty := t; (* swap *)
- end;
- if (lx > rx) then
- begin
- t := lx; lx := rx; rx := t; (* swap *)
- end;
- x := lx;
-
- y := (by + (rth div 2)); (* + rth for {h,v}-space *)
- width := rx - lx;
- height := rth;
- end;
-
- isetpos (x, y);
- cmd1byte (PUTRULE);
- cmd4byte (height);
- cmd4byte (width);
-
- (* output two dots on ends of the rules
- at lx, by and rx, ty *)
- (* the font has already been set before these calls *)
- Tyldot (lx, by);
- Tyldot (rx, ty);
- isetpos (rx, ty);
- end;
-
-
- {------------------------------------------------------------}
- procedure diagonal (xl, yb, xr, yt : ScaledPts; fontindex: integer);
- var t, curx, cury, dx, dy, code : integer;
- slope : real;
- mxveclen : ScaledPts;
- sptovecs : real;
- rho : ScaledPts;
-
- {......................................}
- (* compute maximum length vector character that we can use *)
-
- procedure getincr (var outdx, outdy : integer);
- label 99;
- var radius, x, y : integer;
- sign : integer;
- q : real;
-
- begin (* getincr *)
- radius := mxveclen; (* radius of semi-square *)
- (* make sure the pt is outside of the semi-square,
- scaling down radius if necessary *)
- while ( ((xr - curx) < radius) and
- (abs (yt - cury) < radius)) do
- begin
- radius := radius div 2;
- end;
- if (slope < 0.0) then (* <0 since in 4th quad by now*)
- sign := -1
- else
- sign := +1;
- if (xr = curx) then
- begin
- outdx := 0;
- outdy := sign * radius;
- goto 99;
- end;
- if (yt = cury) then
- begin
- outdx := abs (radius);
- outdy := 0;
- goto 99;
- end;
-
- (* compute the intersection with the semi-square,
- choose whichever slope is best *)
- if (abs (slope) < 1.0) then
- begin (* mostly horizontal *)
- outdx := abs (radius);
- y := yb + round ((curx + abs(radius) - xl) * slope);
- outdy := y - cury;
- end
- else
- begin (* mostly vertical *)
- x := xl + round ((cury + (sign * radius) - yb) / slope);
- outdx := x - curx;
- outdy := sign * radius;
- end;
-
- if (abs (outdy) > abs (yt - cury)) then
- begin (* truncate *)
- outdy := yt - cury;
- end;
- if (outdx > (xr - curx)) then
- begin (* truncate *)
- outdx := xr - curx;
- end;
- if (outdx < 0) then
- begin
- outdx := 0;
- end;
-
- (* method to find the exact intersection of the line segment
- with the semi-circle, used
- to determine the x and y values::
- we do this by using the arctangent of the slope as
- the angle 'a' from the x-axis. Then use the relation
- y = r cos a, and x = r sin a
- we can be smart about all this trig stuff by using
- the relation :
- sin (arctan a) = 1/sqrt(1 + a^2)
- cos (arctan a) = a/sqrt(1 + a^2)
- Thus:
- q := (1.0 / sqrt (slope * slope + 1.0));
- outdx := round (q * radius);
- outdy := round (q * radius * slope);
-
- Unfortunately, we cannot access the Vector Font
- coding scheme because the outdx, outdy 's produced
- here do no conform to the condition
- max (dx, abs(dy)) in [0,1,2,4,8,16]
- when converted to vector-font sizes with
- sptovecs (see the 'diagonal' proc.).
- *)
-
- 99:
- end; (* getincr *)
- {.......................................}
-
- begin (* DIAGONAL *)
- if (xr <> xl) then
- slope := (yt - yb) / (xr - xl)
- else
- slope := BIGREAL; (* some illegal value *)
-
- if (xl > xr) then
- begin
- t := xl; xl := xr; xr := t;
- t := yb; yb := yt; yt := t;
- end; (* swap *)
-
- curx := xl;
- cury := yb;
- mxveclen := (VFontTable[fontindex]^.MaxVectLen);
- rho := mxveclen div 16; (* minimum radius of vector fonts *)
- if (rho = 0) then
- begin
- complain (ERRREALBAD);
- writeln(logfile,'Diagonal: Min radius of vector font is zero. setting to 1');
- rho := 1;
- end;
-
- if ((abs(xl - xr) <= rho) and
- (abs(yb - yt) <= rho)) then
- begin (* pretty much a null line *)
- Tyldot (xl, yb);
- end
- else
- begin
- sptovecs := 1.0 / rho; (* conversion for scaled pts to vectorfont units *)
-
- code := -1; (* initialize to a bogus number *)
-
- (* this conditional really has to have "or"
- instead of "and", because of lines that are
- *nearly* horizontal or vertical
- *)
- while (((xr - curx) >= rho) or (abs(yt - cury) >= rho)) do
- begin
- (* Get the approximate incremental amount. We use this dy/dx
- pair in order to index into our vector font coding scheme *)
-
- getincr (dx, dy);
-
- (* Get the vector character code corresponding to this
- approximate incremental amount *)
- t := outvector (round (dx * sptovecs),
- round (dy * sptovecs),
- code);
- (* Now that we have the character code, go find out its actual
- physical dimensions for the real dy/dx amounts *)
- if (dy > 0) then
- dy := VFontTable[fontindex]^.FontInfo[code].Cdp
- else
- dy := -(VFontTable[fontindex]^.FontInfo[code].Cht);
-
- dx := VFontTable[fontindex]^.FontInfo[code].Cwd;
-
- case (t) of
- 0: begin
- complain (ERRREALBAD);
- writeln (logfile,'Error in Diagonal:: bad dydx');
- end;
-
- 1: begin
- isetpos (curx, cury);
- iputchar (code);
- end;
-
- 2: begin
- isetpos (curx, cury);
- iputchar (code);
- isetpos (curx + (dx div 2), cury + (dy div 2));
- iputchar (code);
- end;
- end; (* case *)
-
- curx := curx + dx;
- cury := cury + dy;
- end; (* while *)
-
- if ((code >= 0) and
- (((xr - curx) >= rho) and (abs(yt - cury) >= rho))) then
- begin
- iputchar (code);
- end;
- end; (* not null line *)
- end;
-
-
- {-------------------------------------------------------}
- E_O_F
- else
- echo "will not over write ./src/textyl.pas.af"
- fi
- chmod 644 ./src/textyl.pas.af
- if [ `wc -c ./src/textyl.pas.af | awk '{printf $1}'` -ne 26365 ]
- then
- echo `wc -c ./src/textyl.pas.af | awk '{print "Got " $1 ", Expected " 26365}'`
- fi
- echo "Finished archive 5 of 9"
- exit
-